官方
http://research.microsoft.com/en-us/um/cambridge/groups/science/tools/d3/dynamicdatadisplay.htm
Tutorial
http://research.microsoft.com/en-us/um/cambridge/projects/ddd/d3isdk/
D3Overview 必读
http://research.microsoft.com/en-us/um/cambridge/groups/science/tools/d3/D3Overview.pdf
Sliverlight版本: DynamicDataDisplay.2.0.907
Dynamic Data Display 的Sliverlight版本和Wpf版本中的代码不一样.
Markers: Many markers
cs1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43// Copyright © 2010-2011 Microsoft Corporation, All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Resources;
namespace ManyMarkersSample
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
var y = LoadData();
var x = Enumerable.Range(0, y.Length).Select(p => (double)p).ToArray();
markers.MarkersBatchSize = 750;
markers.Plot(x, y);
}
private static double[] LoadData()
{
List<double> data = new List<double>(11000);
StreamResourceInfo sri = Application.GetResourceStream(new Uri("r0001.csv", UriKind.Relative));
using (var sr = new StreamReader(sri.Stream))
{
var s = sr.ReadLine();
while ((s = sr.ReadLine()) != null)
{
var d = double.Parse(s, CultureInfo.InvariantCulture);
data.Add(d);
}
}
return data.ToArray();
}
}
}
This sample renders 11000 markers. Note that markers appear on the screen gradually and quality of zoomed in/zoomed out image also increases gradually. This keeps the sample fully interactive even at the moments when rendering is in progress.
MarkerGraph的继承关系1
2
3
4
5
6
7
8
9
10System.Object
System.Windows.DependencyObject
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Panel
Microsoft.Research.DynamicDataDisplay.PlotBase
Microsoft.Research.DynamicDataDisplay.MarkerGraph
Microsoft.Research.DynamicDataDisplay.BarGraph
Microsoft.Research.DynamicDataDisplay.CartesianMarkerGraph
Microsoft.Research.DynamicDataDisplay.VerticalIntervalGraph
Rendering optimization
Silverlight has limited rendering performance and plotting more than a few thousands of elements takes signification amount of time which is enough to make application non-interactive. Scientific data sets often contain tens of thousands of data items. To overcome Silverlight limitation MarkerGraph uses bitmap caching and deferred rendering. You can see how it works in Many Markers sample in Interactive SDK. Markers appear on the screen in batches. Each new batch is rendered when application is idle, so when user navigated or interacts with UI in other manner markers rendering is suspended. When marker graph needs to be redrawn because of panning or zooming, all batches are instantly replaced with bitmaps which are translated and scaled according to user navigation. After that bitmaps are replaced with real markers batch by batch in application idle moments. You may see it clear when zooming in significantly. Markers became blurred because of bitmap scaling. Later, blurred markers are replaced with re-rendered ones which makes picture look sharp again
User can control this process using two properties. MarkerBatchSize controls size of marker batch rendered at a single pass. Larger values can cause poor application resposiveness for complex marker templates, small values will result in increase of marker graph update time.
1 | class MarkerGraph |
Marker graph rendering is restarted when data are changed. If data changes occur more frequently than application idle times when marker graph draws itself, most or even all of the data updates may be skipped and not shown. MarkerGraph provides technique to wait until current data is completely displayed. Plot method returns rendering task Id. When this task is either completed or skipped because new data arrives task id is observed on RenderCompletion subject. Using this technique, application can wait for markers complete draw before updating data. See ‘Background rendering’ sample in Interactive SDK